<?php
include_only();

$all_languages = get_all_languages();
$upload_subtitle_hint = "<b>if you dont have a subtitle file try free programs such as \"automatic subtitle synchronizer\" to create the subtitle.</b>";

// upload file

$upload_subtitle_form = "
<form enctype=\"multipart/form-data\" action=\"subtitle_importer.php\" method=\"POST\">
<table>
<tr>
<td>subtitle name (optional):</td>
<td><input type='text' name='subtitle_name' style='width:100%'/></td>
</tr>
<tr>
<td>
select video:</td>
<td>
<select id='select_content' name='video_id'>
<option value='-1'>None</option>
";

$userid = get_user_info();
$user_id = $userid['id'];
$videos = get_user_videos($user_id);
$favourite_videos = get_user_favourite_videos($user_id);

for ($i = 0; $i <= count($videos)-1; $i++) {
    $upload_subtitle_form = $upload_subtitle_form . "<option value='".$videos[$i]['id']."'>".$videos[$i]['name']."</option>";
}
for ($i = 0; $i <= count($favourite_videos)-1; $i++) {
    $upload_subtitle_form = $upload_subtitle_form . "<option value='favourites".$favourite_videos[$i]['id']."'>(favourites) ".$favourite_videos[$i]['name']."</option>";
}

$upload_subtitle_form = $upload_subtitle_form .
"</select>
</td></tr>
<tr>
<td>translate from:</td>
<td>
<select name='original_lang'>
<option value='-1'>Select Language</option>
<option value='-1'>None</option>
";
for ($i = 0; $i <= count($all_languages)-1; $i++) {
    $upload_subtitle_form = $upload_subtitle_form . "<option value='".$all_languages[$i]['id']."'>".$all_languages[$i]['name']."</option>";
}
$upload_subtitle_form = $upload_subtitle_form . "
</select>
</td>
</tr>
<tr>
<td>translate to:</td>
<td>
<select name='new_lang'>
<option value='-1'>Select Language</option>
";
for ($i = 0; $i <= count($all_languages)-1; $i++) {
    $upload_subtitle_form = $upload_subtitle_form . "<option value='".$all_languages[$i]['id']."'>".$all_languages[$i]['name']."</option>";
}
   $upload_subtitle_form = $upload_subtitle_form . "
</select>
</td>
</tr>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000000\" />
<tr>
<td>
Choose a file to import:
</td> 
<td><input name=\"uploadedfile\" type=\"file\" /></td>
</tr>
</table>
<br>
<input type='hidden' name='upload_subtitle' value='yes'>
<input type=\"submit\" value=\"Upload File\" />

</form>
		<br /><div id=\"progressbar\"></div>
";


// import text

$import_subtitle_text = "
<b>use this option if</b> :<br>
1- you want to create an empty subtitle.<br>
2- or if you have a problem with the subtitle chracter encoding after uploading the subtitle. then open the subtitle file with any text editor select all then copy then paste it here.<br><br>
<form enctype=\"multipart/form-data\" action=\"subtitle_importer.php\" method=\"POST\">
<table>
<tr>
<td>subtitle name (optional):</td>
<td><input type='text' name='subtitle_name' style='width:100%'/></td>
</tr>
<tr>
<td>
select video:</td>
<td>
<select id='select_content' name='video_id'>
<option value='-1'>None</option>
";

$userid = get_user_info();
$user_id = $userid['id'];
$videos = get_user_videos($user_id);
$favourite_videos = get_user_favourite_videos($user_id);
for ($i = 0; $i <= count($videos)-1; $i++) {
    $import_subtitle_text = $import_subtitle_text . "<option value='".$videos[$i]['id']."'>".$videos[$i]['name']."</option>";
}
for ($i = 0; $i <= count($favourite_videos)-1; $i++) {
    $import_subtitle_text = $import_subtitle_text . "<option value='favourites".$favourite_videos[$i]['id']."'>(favourites) ".$favourite_videos[$i]['name']."</option>";
}

$import_subtitle_text = $import_subtitle_text .
"</select>
</td></tr>
<tr>
<td>translate from:</td>
<td>
<select name='original_lang'>
<option value='-1'>Select Language</option>
<option value='-1'>None</option>
";
for ($i = 0; $i <= count($all_languages)-1; $i++) {
    $import_subtitle_text = $import_subtitle_text . "<option value='".$all_languages[$i]['id']."'>".$all_languages[$i]['name']."</option>";
}
$import_subtitle_text = $import_subtitle_text . "
</select>
</td>
</tr>
<tr>
<td>translate to:</td>
<td>
<select name='new_lang'>
<option value='-1'>Select Language</option>
";
for ($i = 0; $i <= count($all_languages)-1; $i++) {
    $import_subtitle_text = $import_subtitle_text . "<option value='".$all_languages[$i]['id']."'>".$all_languages[$i]['name']."</option>";
}
   $import_subtitle_text = $import_subtitle_text . "
</select>
</td>
</tr>
<input type=\"hidden\" name=\"MAX_FILE_SIZE\" value=\"100000000\" />
<tr>
<td  colspan='2'>
<br>
paste subtitle text here or leave empty :<br>
<textarea name='subtitle_text' cols='75' rows='5'></textarea>
</td>
</tr>
</table>
<br>
<input type='hidden' name='create_subtitle' value='yes'>
<input type=\"submit\" value=\"Create Subtitle\" />

</form>
		<br /><div id=\"progressbar\"></div>
";
?>
